package com.zyh.homework.test2;

import java.io.*;

/**
 * @Author zyh
 * @Date 2024/8/6 17:28
 * @Description
 * 1、使用从键盘输入三句话，用PrintStream打印到一个words.txt文件中
 * 2、再用Scanner一行一行读取显示
 * 示例文字：
 *      好好学习
 *      天天向上
 *      你好世界
 */

public class Test2 {
    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入第" + (i + 1) + "句话：");
            String s = br.readLine();
            PrintStream ps = new PrintStream(new FileOutputStream("D:\\Code\\IDEA\\idea_projects\\JavaSE-plus\\day10-code\\src\\com\\zyh\\homework\\test2\\words.txt", true));
            ps.println(s);
        }
        BufferedReader br1 = new BufferedReader(new FileReader("D:\\Code\\IDEA\\idea_projects\\JavaSE-plus\\day10-code\\src\\com\\zyh\\homework\\test2\\words.txt"));
        String line = null;
        while ((line = br1.readLine()) != null) {
            System.out.println(line);
        }
    }
}
